package com.zhilingshenghuo.app.zhly.view.adapter

import android.graphics.Color
import com.zhilingshenghuo.app.zhly.R
import com.zhilingshenghuo.app.zhly.entity.RobRecordResponse
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class RobRecordAdapter :
    BaseQuickAdapter<RobRecordResponse.ListBean.DataBean, BaseViewHolder>(R.layout.item_rob_record) {
    override fun convert(holder: BaseViewHolder, item: RobRecordResponse.ListBean.DataBean) {
        holder.setText(R.id.tvTitle, item.room.title)
        holder.setText(R.id.tvUserName, item.room.title)
        holder.setText(R.id.tvDate, item.rob_time)
        if (item.claim_score.toDouble() > 0) {
            holder.setText(R.id.tvStatus, item.rob_score + "金币(中雷)")
            if (item.rob_score.toDouble() >= item.claim_score.toDouble()) {
                holder.setTextColor(R.id.tvHaveCoin, Color.parseColor("#FF6325"))
                holder.setText(
                    R.id.tvHaveCoin,
                    "+" + (item.rob_score.toDouble() - item.claim_score.toDouble())
                )
            } else {
                holder.setTextColor(R.id.tvHaveCoin, Color.parseColor("#45C53B"))
                holder.setText(
                    R.id.tvHaveCoin,
                    "" + (item.rob_score.toDouble() - item.claim_score.toDouble())
                )
            }

        } else {
            holder.setText(R.id.tvStatus, item.rob_score + "金币(未中雷)")
            holder.setTextColor(R.id.tvHaveCoin, Color.parseColor("#FF6325"))
            holder.setText(R.id.tvHaveCoin, "+" + item.rob_score)
        }


//        when (item.status) {
//            "finish" -> {
//                holder.setText(R.id.tvStatus, "已结束")
//                holder.setText(R.id.tvHaveCoin, "订单完成")
//            }
//            "wait" -> {
//                holder.setText(R.id.tvStatus, "进行中")
//                holder.setText(R.id.tvHaveCoin, "等待结算")
//            }
//        }
        holder.setText(R.id.tvSelectNums, "雷号" + item.order.select_num)
    }
}